package com.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pojo.entity.CFriends;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface FriendMapper extends BaseMapper<CFriends> {

    //查询某个用户的所有的好友id
    @Select("SELECT friend_id \n" +
            "FROM friends\n" +
            "WHERE user_id =#{userId} and state=2\n" +
            "UNION ALL \n" +
            "SELECT user_id \n" +
            "FROM friends\n" +
            "WHERE friend_id=#{userId} AND state=2")
    List<Long> getFriendIds(Long userId);
}
